﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.ComponentModel;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace elevator
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        car cab;

        public MainWindow()
        {
            InitializeComponent();

            cab = new car();
            cab.CurrentFloor = 0;
            Binding binding = new Binding();
            binding.Source = cab;
            binding.Path = new PropertyPath("CurrentFloor");
            BindingOperations.SetBinding(showFloor, TextBox.TextProperty, binding);

            Binding staBinding = new Binding();
            staBinding.Source = cab;
            staBinding.Path = new PropertyPath("CarStatus");
            BindingOperations.SetBinding(showStatus, TextBox.TextProperty, staBinding);

            Binding doorBinding = new Binding();
            doorBinding.Source = cab;
            doorBinding.Path = new PropertyPath("DoorStatus");
            BindingOperations.SetBinding(showDoorStatus, TextBox.TextProperty, doorBinding);

            foreach (Button item in rouqi.Children)
            {
                item.Click += button_Click;
            }
        }

        private async void button_Click(object sender, RoutedEventArgs e)
        {
            Button btn = (Button)sender;
            int whichB = int.Parse((string)btn.Content);
            await cab.pressFloorAsync(whichB);
            //MessageBox.Show("");
        }

        private void f3_Click(object sender, RoutedEventArgs e)
        {
            //cab.CurrentFloor += 1;
        }
    }
}
